// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 * Author: Huawei OS Kernel Lab
 * Create: Thu Aug 15 16:14:23 2023
 */

#include <stdarg.h>
#include <linux/module.h>
#include <linux/kernel.h>

int __request_module(bool wait, const char *fmt, ...)
{
	va_list args;
	char module_name[MODULE_NAME_LEN];
	int ret;

	if (!wait) {
		pr_info("~~ UN-IMPL ~~: %s() NO_WAIT\n", __func__);
		return -EINVAL;
	}

	va_start(args, fmt);
	ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
	va_end(args);
	if (ret >= MODULE_NAME_LEN)
		return -ENAMETOOLONG;

	if (strcmp(module_name, "fixed-partitions") == 0)
		request_module("ofpart.ko");

	return liblinux_pal_request_module(module_name);
}
EXPORT_SYMBOL(__request_module);

/* for mem stat */
EXPORT_SYMBOL(__module_text_address);
